<template>
  <div class="root">
    <Header style="top: -12px; z-index: 9999" v-if="showCard"></Header>
    <hr />
    <div class="main">
      <router-view v-if="showCard" />
    </div>
  </div>
</template>
<script>
import Header from "./nav/Header";
import { getUserInfo } from "@/api/userApi";
export default {
  data() {
    return {
      showCard: false,
      layer: null,
    };
  },
  components: {
    Header
  },
  created() {
    layer.load();
    if (this.$cookie.get("token") != null) {
      getUserInfo().then((res) => {
        if (res.code == 0) {
          this.$store.commit("setUsetInfo", res.data.userData);
          this.$store.commit("setAddress", res.data.addressData);
          //  console.log(res.data)
          // console.log(res.data)
          this.showCard = true;
        } else {
          this.$store.commit("setUsetInfo", null);
        }
        layer.closeAll("loading");
      });
    } else {
      layer.closeAll("loading");
      this.showCard = true;
      this.$store.commit("setUsetInfo", null);
    }
  },
  mounted() {},
};
</script>
<style lang="scss" scoped>
.root {
  // position: sticky;

  // .main {
  //  margin-left: 230px;
  // }
}
</style>